<template>
  <div class="openOrder">
    <!-- 顶部查询表单 -->
    <div class="openOrderTop">
      <el-form ref="searchForm" :model="queryParam" :inline="true" size="mini">
        <!-- <el-col :span="5"> -->
        <el-form-item label="客户:" prop="customer">
          <!--<el-select clearable filterable v-model="queryParam.customerInfo" style="width: 180px">-->
          <!--  <el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in payCustomerDropdowm"></el-option>-->
          <!--</el-select>-->
          <el-input clearable placeholder="请输入供应商名称" size="mini" style="width: 180px" v-model="queryParam.customerInfo"></el-input>
        </el-form-item>
        <!-- </el-col> -->
        <!-- <el-col :span="5"> -->
        <el-form-item label="结算单编号:">
          <el-input clearable placeholder="请输入结算单编号" size="mini" style="width: 180px" v-model="queryParam.billCode"></el-input>
        </el-form-item>
        <!-- </el-col> -->
        <!-- <el-col :span="8"> -->
        <el-form-item label="结算时间:">
          <el-date-picker clearable placeholder="请选择开始时间" style="width: 180px" type="datetime" v-model="queryParam.startTime"></el-date-picker>
          -
          <el-date-picker clearable placeholder="请选择结束时间" style="width: 180px" type="datetime" v-model="queryParam.endTime"></el-date-picker>
        </el-form-item>
        <!-- </el-col> -->
        <el-form-item label="委托书编号:">
          <el-input clearable size="mini" placeholder="请输入委托书编号" style="width: 170px" v-model="queryParam.contractNo"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="mini" @click="initMainTable">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="openTitle">对账单列表</div>
    <!-- 按钮组 -->
    <div class="btn">
      <buttonName @clickEvent="clickEvent"></buttonName>
      <!--      <el-button-->
      <!--        v-if="isAuth('print')"-->
      <!--        size="mini"-->
      <!--        plain-->
      <!--        type="primary"-->
      <!--        @click="print"-->
      <!--      >导出对账单-->
      <!--      </el-button>-->
      <!--      <el-button-->
      <!--        v-if="isAuth('confirmPayment')"-->
      <!--        size="mini"-->
      <!--        plain-->
      <!--        type="primary"-->
      <!--        @click="confirmPayment"-->
      <!--      >付款确认-->
      <!--      </el-button>-->
      <!--      <el-button-->
      <!--        v-if="isAuth('collection')"-->
      <!--        size="mini"-->
      <!--        plain-->
      <!--        type="primary"-->
      <!--        @click="confirmPCollect"-->
      <!--      >收款确认-->
      <!--      </el-button>-->
    </div>
    <!-- 主要表格 -->
    <split-pane split="horizontal" v-on:resize="resize" :min-percent="20" :default-percent="50">
      <template slot="paneL">
        <div class="openOrderBox" ref="tableH" style="height: 100%">
          <!-- 结算单列表 表格 -->
          <el-tabs v-model="actionName" type="card" @tab-click="tabsClick">
            <el-tab-pane label="陆运结算" name="way">
              <div class="openLeftTableBox">
                <el-table
                  :data="mainPayDataTable.data"
                  border
                  :header-cell-style="{ textAlign: 'center' }"
                  highlight-current-row
                  @row-click="mainTableRowClick"
                  @selection-change="selectionChange"
                  :height="maxHeight"
                  ref="wayTableRef"
                >
                  <el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
                  <el-table-column align="center" type="selection" width="55"></el-table-column>
                  <el-table-column align="center" prop="status" label="状态" show-overflow-tooltip width="140">
                    <template slot-scope="scope">{{ billStatus(scope.row) }}</template>
                  </el-table-column>
                  <el-table-column align="center" prop="type" label="费目" show-overflow-tooltip width="100"></el-table-column>
                  <el-table-column align="center" prop="name" label="结算单名称" width="120" show-overflow-tooltip></el-table-column>
                  <el-table-column align="center" prop="code" label="结算单号" show-overflow-tooltip width="250">
                    <template v-slot="scope">
                      <el-popover placement="right" width="500" v-model="annexFileTableShow[scope.$index]" trigger="manual" title="附件列表">
                        <el-table border :header-cell-style="{ textAlign: 'center' }" :data="reviewFileList" size="mini">
                          <el-table-column align="center" label="序号" type="index" width="55"></el-table-column>
                          <el-table-column align="center" label="名称" prop="aName"></el-table-column>
                          <el-table-column align="center" width="80">
                            <template v-slot="scope">
                              <el-button type="primary" size="mini" circle icon="el-icon-download" @click="downReviewAnnexFile(scope.row)"></el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                        <u slot="reference" @click="showDetail(scope)">{{ scope.row.code }}</u>
                      </el-popover>
                    </template>
                  </el-table-column>
                  <el-table-column align="center" prop="acode" label="订单号" show-overflow-tooltip width="200"></el-table-column>
                  <el-table-column align="center" width="120px" prop="payer" label="结算对象" show-overflow-tooltip></el-table-column>
                  <el-table-column align="center" prop="cmtNo" label="委托书编号" show-overflow-tooltip width="200"></el-table-column>
                  <el-table-column align="center" prop="loadingPlace" label="装货地点" show-overflow-tooltip width="250"></el-table-column>
                  <el-table-column align="center" prop="unloadPlace" label="收货地点" show-overflow-tooltip width="250"></el-table-column>
                  <el-table-column align="center" prop="weight" label="吨数" show-overflow-tooltip></el-table-column>
                  <el-table-column align="center" prop="price" label="单价(元/吨)" show-overflow-tooltip width="120"></el-table-column>
                  <el-table-column align="center" prop="totalPrice" label="金额(元)" show-overflow-tooltip></el-table-column>
                  <el-table-column align="center" prop="remark" label="备注" show-overflow-tooltip></el-table-column>
                </el-table>
              </div>
              <!-- 分页 -->
              <div class="block">
                <el-pagination
                  ref="pagination"
                  small
                  background
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="Pagination.currentPage"
                  :page-sizes="Pagination.pageSizeList"
                  :page-size="Pagination.PageSize"
                  :layout="Pagination.layout"
                  :total="Pagination.total"
                ></el-pagination>
              </div>
            </el-tab-pane>
            <el-tab-pane name="sea" label="海运结算">
              <el-table
                :data="infoPayTable.data"
                border
                @selection-change="selectionChange"
                :header-cell-style="{ textAlign: 'center' }"
                highlight-current-row
                @row-click="mainTableRowClick"
                :height="maxHeight"
                ref="seaTableRef"
              >
                <el-table-column align="center" type="selection" width="55"></el-table-column>
                <el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
                <el-table-column align="center" prop="status" label="状态" width="100" show-overflow-tooltip>
                  <template slot-scope="scope">{{ billStatus(scope.row) }}</template>
                </el-table-column>
                <el-table-column align="center" prop="type" label="费目" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="name" label="结算单名称" width="120" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="code" label="结算单号" show-overflow-tooltip width="250">
                  <template v-slot="scope">
                    <el-popover placement="right" width="500" v-model="annexFileTableShow[scope.$index]" trigger="manual" title="附件列表">
                      <el-table border :header-cell-style="{ textAlign: 'center' }" :data="reviewFileList" size="mini">
                        <el-table-column align="center" label="序号" type="index" width="55"></el-table-column>
                        <el-table-column align="center" label="名称" prop="aName"></el-table-column>
                        <el-table-column align="center" width="80">
                          <template v-slot="scope">
                            <el-button type="primary" size="mini" circle icon="el-icon-download" @click="downReviewAnnexFile(scope.row)"></el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                      <u slot="reference" @click="showDetail(scope)">{{ scope.row.code }}</u>
                    </el-popover>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="acode" label="订单号" show-overflow-tooltip width="200"></el-table-column>
                <el-table-column align="center" width="120px" prop="payName" label="结算对象" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="cmtNo" label="委托书编号" show-overflow-tooltip width="200"></el-table-column>
                <el-table-column align="center" prop="loadingPlace" label="装货地点" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="unloadPlace" label="收货地点" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="weight" label="总重(吨)" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="price" label="单价(元/吨)" width="120" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="totalPrice" label="金额(元)" show-overflow-tooltip></el-table-column>
                <el-table-column align="center" prop="remark" label="备注" show-overflow-tooltip></el-table-column>
              </el-table>
              <div class="block">
                <el-pagination
                  class="pagination"
                  small
                  background
                  @size-change="infoHandleSizeChange"
                  @current-change="infoHandleCurrentChange"
                  :current-page="infoPayTable.pageInfo.index"
                  :page-sizes="Pagination.pageSizeList"
                  :page-size="infoPayTable.pageInfo.size"
                  :layout="Pagination.layout"
                  :total="infoPayTable.pageInfo.total"
                ></el-pagination>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
      </template>
      <template slot="paneR">
        <div ref="billItemRef" style="height: 80%">
          <el-table :data="billItemTable.data" border :height="itemHeight">
            <el-table-column width="55" show-overflow-tooltip align="center" type="index" label="序号"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="conNo" label="委托书编号" width="180"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="wcdSttime" label="装货日期" width="180"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="startPlace" label="装货地点" width="200"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="endPlace" label="收获地点" width="200"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="goodsName" label="货名"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="trkNo" label="车号"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="allWeight" label="吨数"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="ctrNo" label="箱号" v-if="actionName == 'sea'"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="sealNo" label="铅封号" v-if="actionName == 'sea'"></el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="transportQuantity" label="费用信息">
              <el-table-column show-overflow-tooltip align="center" prop="price" label="运输单价(元/吨)" width="150"></el-table-column>
              <el-table-column show-overflow-tooltip align="center" prop="allWeight" label="总重(吨)"></el-table-column>
              <el-table-column show-overflow-tooltip align="center" prop="allPrice" label="费用" width="150"></el-table-column>
            </el-table-column>
          </el-table>
        </div>
      </template>
    </split-pane>

    <el-dialog
      :title="reviewDialog.title"
      :visible.sync="reviewDialog.show"
      :close-on-click-modal="false"
      v-el-drag-dialog
      v-dialogDrag
      width="30%"
      @close="reviewDialogClose"
    >
      <el-row align="center">
        <el-col align="center">
          <el-upload
            :data="reviewDialog.data"
            ref="reviewUploadFileRef"
            class="upload-demo"
            drag
            :file-list="reviewDialog.fileList"
            :action="uploadAction"
            :auto-upload="false"
            multiple
            name="file"
            :on-success="reviewFileUploadSuccess"
            :headers="{ Token: $store.state.user.Session_Token, pageUrl: $store.state.app.mdlUrl.replace('/layout', '') }"
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip" slot="tip">文件不超过5M</div>
          </el-upload>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="reviewDialog.show = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="doCheck">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 结算单查看 dialog -->
    <viewDialog :info="viewDialogData" @dialogClose="dilaogClose"></viewDialog>
  </div>
</template>

<script>
import paginationMixin from '@/mixins/pagination'
import isAuth from '@/mixins/buttonAuth'
import resizeMixin from '@/mixins/resize'
import viewDialog from '@/views/cstManagement/twoCstManagement/expenseSettlement/viewDialog'
import buttonName from '@/components/buttonName/button-name'
import { confirmationResultsList, getFileList, queryBillItem, queryPlatformCustomerBill, queryPlatformCustomerDropDownBill } from '@/request/api'
import store from '@/store'
import { exportStatement } from '@/request/cstManagement/expenseSettlement'

export default {
  mixins: [resizeMixin, paginationMixin, isAuth],
  data() {
    return {
      selected: [],
      currentData: {},
      actionName: 'way',
      maxHeight: -1,
      itemHeight: -1,
      // 下拉框
      payCustomerDropdowm: [], // 结算对象下拉
      queryParam: {
        customerInfo: '', // 结算对象，
        billCode: '', // 结算单编号
        startTime: null,
        endTime: null,
        contractNo: '',
      },
      // 页面结算对象表格
      mainPayDataTable: {
        data: [],
        currentData: {},
      },
      // 查看dialog
      viewDialogData: {
        title: '',
        show: false,
        currentData: {},
        selectionArr: [],
        btn: '',
        btnShow: true,
        source: 3,
        tagName: '',
        documentNoDisable: true,
      },
      infoPayTable: {
        data: [],
        currentData: {},
        pageInfo: {
          index: 1,
          size: 30,
          total: 0,
        },
      },
      billItemTable: {
        data: [],
      },
      // 当前结算对象
      currentPay: '',
      selectionArr: [],
      reviewDialog: {
        show: false,
        title: '',
        data: {
          json: '',
        },
        fileList: [],
      },
      annexFileTableShow: [],
      reviewFileList: [],
    }
  },
  components: {
    viewDialog,
    buttonName,
  },
  computed: {
    uploadAction() {
      return process.env.NODE_ENV === 'production' ? '' : '/proxy' + '/FTKJWLHYPT/bill/reviewUploadFile'
    },
    billStatus() {
      return row => {
        let item = localStorage.getItem('IS_SHOW1')
        if (item == 5 && row.status === '已付款') {
          return '对方已经付款'
        }
        return row.status
      }
    },
  },
  created() {
    this.resize = () => {
      this.maxHeight = this.$refs.tableH.offsetHeight - 110
      this.itemHeight = this.$refs.billItemRef.offsetHeight + 50
    }
  },
  mounted() {
    this.initMainTable()
    // this.initPayCustomerDropdowm()
  },
  methods: {
    clickEvent(val) {
      if (val.mdlCode === 'print') {
        this.print()
      }
      if (val.mdlCode === 'confirmPayment') {
        this.confirmPayment()
      }
      if (val.mdlCode === 'collection') {
        this.confirmPCollect()
      }
      if (val.mdlCode === 'initiate') {
        this.initiate()
      }
      if (val.mdlCode === 'view') {
        this.view()
      }
      if (val.mdlCode === 'push') {
        this.push()
      }
      if (val.mdlCode === 'check') {
        this.check()
      }
    },
    // 初始化主表
    initMainTable() {
      let source, cbJpayer, cbFltId, preDptId
      let u = (localStorage.getItem('IS_SHOW1') || '').toString()
      if (u === '5') {
        // 平台
        source = 2
        cbJpayer = this.queryParam.customerInfo
      } else if (u === '2') {
        // 集团
        preDptId = store.state.user.DPTID_DX_H
      } else {
        // 糖厂 货主
        cbJpayer = store.state.user.DPTID_DX_H
        cbFltId = this.queryParam.customerInfo
      }
      queryPlatformCustomerBill({
        index: this.currentActionName == 'way' ? this.Pagination.currentPage : this.infoPayTable.pageInfo.index,
        size: this.currentActionName == 'way' ? this.Pagination.pageSize : this.infoPayTable.pageInfo.size,
        cbBillType: this.queryParam.billType,
        cbType: this.actionName,
        cbBillNo: this.queryParam.billCode,
        startTime: this.queryParam.startTime,
        endTime: this.queryParam.endTime,
        contractNo: this.queryParam.contractNo,
        source,
        cbJpayer,
        cbFltId,
        preDptId,
      }).then(res => {
        if (this.actionName == 'way') {
          this.mainPayDataTable.data = res.data
          this.updatePaginationTotal(res.total)
        } else {
          this.infoPayTable.data = res.data
          this.infoPayTable.pageInfo.total = res.total
        }
        for (let i = 0; i < res.data.length; i++) {
          this.annexFileTableShow[i] = false
        }
      })
    },
    getList() {
      this.initMainTable()
    },
    initPayCustomerDropdowm() {
      let data = {}
      let u = localStorage.getItem('IS_SHOW1')
      if (u == 5) {
        data.source = 2
      }
      queryPlatformCustomerDropDownBill(data).then(res => {
        this.payCustomerDropdowm = res.data
      })
    },
    initBillItemTable() {
      queryBillItem({
        billId: this.currentData.id,
      }).then(res => {
        this.billItemTable.data = res.data
      })
    },
    // 导出
    print() {
      const data = this.selected
      if (!data.length) {
        this.$message.error({
          message: '至少选择一项',
          showClose: true,
        })
        return
      }
      for (let datum of data) {
        if (datum.payName !== data[0].payName) {
          this.$message.error({
            message: '请选择相同的结算对象',
            showClose: false,
          })
          return
        }
      }
      exportStatement({
        ids: data.map(value => {
          return value.id
        }),
        type: 0,
        yht: 'gys',
        section: this.actionName,
      }).then(res => {
        const fileName = decodeURI(res.headers['filename'])
        const reader = new FileReader()
        reader.readAsDataURL(new Blob([res.data]))
        reader.onload = e => {
          let a = document.createElement('a')
          a.download = fileName
          a.href = e.target.result
          document.body.appendChild(a)
          a.click()
          document.body.removeChild(a)
        }
        window.parent._$store.dispatch('app/loading_status', false)
        this.initMainTable()
      })
    },
    // 付款确认
    confirmPayment() {
      const data = this.selected
      if (!data.length) {
        this.$message.error({
          showClose: true,
          message: '至少选择一项',
        })
        return
      }
      for (let datum of data) {
        if (datum.statusCode.toString() === '4') {
          this.$message.error({
            message: `${datum.code}不要重复确认`,
            showClose: true,
          })
          return
        }
        if (datum.statusCode.toString() !== '2' && datum.statusCode.toString() !== '3') {
          this.$message.error({
            message: `${datum.code}对方未发起或者未确认，无法付款确认`,
            showClose: true,
          })
          return
        }
      }
      confirmationResultsList({
        ids: data.map(value => {
          return value.id
        }),
        status: '4',
      }).then(() => {
        this.$message.success({
          showClose: true,
          message: '付款确认成功',
        })
        this.initMainTable()
      })
    },
    mainTableRowClick(val) {
      this.$refs[`${this.actionName}TableRef`].toggleRowSelection(val)
      this.currentData = val
      console.log(val)
      this.initBillItemTable()
    },
    tabsClick({ name }) {
      this.selected = []
      this.actionName = name
      this.viewDialogData.tagName = name
      this.currentData = {}
      this.billItemTable.data.length = 0
      this.initMainTable()
    },
    dilaogClose() {
      this.currentData = {}
      this.initMainTable()
      this.initPayCustomerDropdowm()
    },
    // 收款确认
    confirmPCollect() {
      const data = this.selected
      if (!data.length) {
        this.$message.error({
          showClose: true,
          message: '至少选择一项',
        })
        return
      }
      for (let datum of data) {
        if (datum.statusCode.toString() === '5') {
          this.$message.error({
            message: '不要重复确认',
            showClose: true,
          })
          return
        }
        if (datum.statusCode.toString() !== '4') {
          this.$message.error({
            message: '对方未付款，无法收款确认',
            showClose: true,
          })
          return
        }
      }
      confirmationResultsList({
        ids: data.map(value => {
          return value.id
        }),
        status: '5',
      }).then(() => {
        this.$message.success({
          showClose: true,
          message: '收款确认成功',
        })
        this.initMainTable()
      })
    },
    initiate() {
      if (!this.selected.length) {
        this.$message.error({
          showClose: true,
          message: '至少选择一项',
        })
        return
      }
      for (let datum of this.selected) {
        if (datum.payName !== this.selected[0].payName) {
          this.$message.error({
            message: '请选择相同的结算对象',
            showClose: false,
          })
          return
        }
        if (datum.statusCode.toString() === '2') {
          this.$message.error({
            message: `${datum.code}重复发起`,
            showClose: true,
          })
          return
        }
        if (datum.statusCode.toString() !== '3') {
          this.$message.error({
            message: `${datum.code}账单不是确认状态`,
            showClose: true,
          })
          return
        }
      }
      if (!Object.keys(this.currentData).length) {
        this.currentData = this.selected[0]
      }
      this.viewDialogData.list = this.selected
      this.viewDialogData.currentData = this.currentData
      this.viewDialogData.currentData.interimStatus = '2'
      this.viewDialogData.btnShow = true
      this.viewDialogData.btn = '确定'
      this.viewDialogData.title = '发起收款'
      this.viewDialogData.show = true
      this.viewDialogData.documentNoDisable = false
      this.viewDialogData.uploadFileShow = true
    },
    view() {
      if (Object.keys(this.currentData).length === 0) {
        this.$message.error('至少选择一条查看')
        return
      }
      this.viewDialogData.currentData = this.currentData
      this.viewDialogData.btnShow = false
      this.viewDialogData.title = '查看'
      this.viewDialogData.show = true
      this.viewDialogData.documentNoDisable = true
      this.viewDialogData.uploadFileShow = false
    },
    // 显示详细
    showDetail({ row, $index }) {
      const currentRole = localStorage.getItem('IS_SHOW1').toString()
      if (row.statusCode === '3' && currentRole === '5') {
        if (!this.annexFileTableShow[$index]) {
          getFileList({
            pubId: row.id,
            module: 'JSSH',
          }).then(res => {
            this.reviewFileList = res.data
            this.$nextTick(() => {
              this.annexFileTableShow[$index] = !this.annexFileTableShow[$index]
            })
          })
        } else {
          this.annexFileTableShow[$index] = !this.annexFileTableShow[$index]
        }
      } else {
        this.viewDialogData.currentData = row
        this.viewDialogData.documentNoDisable = true
        this.viewDialogData.uploadFileShow = false
        this.viewDialogData.btnShow = false
        this.viewDialogData.title = '详细信息'
        this.viewDialogData.show = true
        this.viewDialogData.tagName = this.actionName
      }
    },
    selectionChange(rows) {
      this.selected = rows
    },
    infoHandleSizeChange(val) {
      this.infoPayTable.pageInfo.size = val
      this.initMainTable()
    },
    infoHandleCurrentChange(val) {
      this.infoPayTable.pageInfo.index = val
      this.initMainTable()
    },
    push() {
      if (!this.selected.length) {
        this.$message.error('至少选择一项')
        return
      }
      for (let item of this.selected) {
        if (item.statusCode === 'PUSH') {
          this.$message.error('不能重复推送')
          return
        }
        if (item.statusCode !== '1') {
          this.$message.error(`${item.code}不是未推送状态`)
          return
        }
      }
      confirmationResultsList({
        ids: this.selected.map(value => {
          return value.id
        }),
        status: 'PUSH',
      }).then(() => {
        this.$message.success('推送成功')
        this.initMainTable()
      })
    },
    check() {
      if (!this.selected.length) {
        this.$message.error({
          showClose: false,
          message: '至少选择一项',
        })
        return
      }
      for (let item of this.selected) {
        if (item.statusCode.toString() === '3') {
          this.$message.error({
            message: '不要重复确认',
            showClose: true,
          })
          return
        }
        if (item.statusCode.toString() !== 'PUSH') {
          this.$message.error({
            message: '请选择对方推送数据',
            showClose: true,
          })
          return
        }
      }
      this.reviewDialog.show = true
      this.reviewDialog.title = '添加附件'
    },
    reviewFileUploadSuccess(res, file, fileList) {
      for (let item of fileList) {
        if (item.status !== 'success') {
          return
        }
      }
      this.reviewDialog.show = false
      this.$message.success('上传成功')
      this.$refs['reviewUploadFileRef'].clearFiles()
    },
    doCheck() {
      if (!this.$refs['reviewUploadFileRef'].uploadFiles.length) {
        this.$message.error('至少添加一个附件')
        return
      }
      this.reviewDialog.data.json = JSON.stringify(
        Object.assign({}, this.selected[0], {
          documents: [],
          cbEditer: this.$store.state.user.USR_CODE_DX_H,
          cbBillStatus: '3',
          cbId: this.selected[0].id,
        })
      )
      this.$refs['reviewUploadFileRef'].submit()
      this.reviewDialog.show = false
    },
    downReviewAnnexFile(file) {
      const a = document.createElement('a')
      a.download = file.aName
      if (process.env.NODE_ENV === 'development') {
        a.href = `/${window._$api.PROXYURL}${file.aPath}`
      } else {
        a.href = file.aPath
      }
      a.click()
      document.removeChild(a)
    },
    reviewDialogClose() {
      this.initMainTable()
      this.reviewDialog.data.json = ''
    },
  },
}
</script>

<style lang="scss" scoped>
.openOrder {
  height: 100%;
  width: 100%;
  padding-left: 10px;
  padding-top: 10px;
}

.openOrderBox {
  // height: calc(100vh - 300px);
  // width: 100%;
  // display: flex;
  // .openOrderLeft {
  //   flex: 1;
  // }
}

.openTitle {
  font-size: 13px;
}

.btn {
  padding-top: 10px;
  padding-bottom: 10px;
}

::v-deep .splitter-pane-resizer.horizontal {
  margin-top: -15px;
}
</style>
